﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KhachSan.Process.Public;
namespace KhachSan.Process.Private.Bo
{
    public partial class UC_QuanLyNhom : UserControl
    {
        public UC_QuanLyNhom()
        {
            InitializeComponent();
        }
        DataTable bang;
        private void QuanLyNhom_Resize(object sender, EventArgs e)
        {
            int top = 100;
            int buttonWidth = 70;
            int width=  this.Width / 2-buttonWidth/2;
            this.gcQuyenHienTai.SetBounds(0, top,width, gcQuyenHienTai.Height);
            this.gcChucNangChuaChon.SetBounds(width + buttonWidth, top,width, gcChucNangChuaChon.Height);
            this.pnDanhSach.SetBounds(width, top, pnDanhSach.Width, pnDanhSach.Height);
        }

        private void QuanLyNhom_Load(object sender, EventArgs e)
        {
            XLDuLieu.LoadCombobox("Select * from NhomQuyen", "TenNhom", "MaNhom", cbNhom);
            bang = XLDuLieu.LoadDataTable("Select * from ChucNang");
            cbcChucNang.DataSource = bang;
            cbcChucNang.DisplayMember = "TenChucNang";
            cbcChucNang.ValueMember = "MaChucNang";
        }

        private void cbNhom_Properties_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
        
            
        }

        private void cbNhom_EditValueChanged(object sender, EventArgs e)
        {
            string value = cbNhom.EditValue.ToString();
            DataTable bang = XLDuLieu.LoadDataTable("Select * from ChucNang_NhomQuyen join ChucNang on ChucNang_NhomQuyen.MaChucNang=ChucNang.MaChucNang where MaNhom=" + value);
            cbChucNangDuocTruyCap.DataSource = bang;
            cbChucNangDuocTruyCap.DisplayMember = "TenChucNang";
            cbChucNangDuocTruyCap.ValueMember = "MaChucNang";
        }

        private void bnThemMot_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < cbcChucNang.SelectedItems.Count; i++)
            {
                DataRowView row=(DataRowView)cbcChucNang.SelectedItems[i];
               
            }
        }
    }
}
